<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Jan 23, 2009
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/myjobs.php
 ^
 * Description: template view for my jobs
 ^
 * History:		NONE
 ^
 */

defined('_JEXEC') or die('Restricted access');

global $mainframe;
$db = & JFactory::getDBO();
$document =  & JFactory::getDocument();
$model = $this->getModel('wrecruit', 'WRecruitModel');
$user	  =  & JFactory::getUser();
$uid    =$user->id;
$sql_job_list = "SELECT job.id FROM ".$db->nameQuote('#__wrecruit_jobs')." AS job JOIN ".$db->nameQuote('#__wrecruit_categories')." AS cat
				ON job.jobcategory=cat.id WHERE job.uid = ".$uid;
$sql_candidatepool = "SELECT candidateid FROM ".$db->nameQuote('#__Vcandidatepool')." 
				WHERE employeruid = ".$uid;
$sql_unread_message = "SELECT MSG.id FROM ".$db->nameQuote('#__wrecruit_messages')." AS MSG 
		LEFT JOIN ".$db->nameQuote('#__wrecruit_candidates')." AS CAND ON MSG.jobseekerid=CAND.id
		INNER JOIN ".$db->nameQuote('#__users')." AS  USR ON CAND.uid= USR.id 
		INNER JOIN ".$db->nameQuote('#__wrecruit_employers')." AS  EMP ON EMP.id= MSG.employerid
		WHERE MSG.isread=0 AND MSG.candidate_sent=1 AND EMP.uid=".$uid;

$total_job = $model->getTotalRows($sql_job_list);
$total_candidate_in_pool = $model->getTotalRows($sql_candidatepool);
$total_unread_message = $model->getTotalRows($sql_unread_message);
?>

<h4>Employer Control Panel</h4>
<ul>
	<li>
	<a	href="<?php echo JURI::base()."index.php?option=com_wrecruit&view=employer&layout=account-profile&Itemid=".JRequest::getVar('Itemid');?>">My account &  company profile</a>
	</li>
	</li>
	<li>
	<a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=myjob&sort=job.created&page=1&Itemid=" .$this->Itemid; ?>">
		My jobs(<?php echo $total_job; ?>)
	</a>
	</li>
	<li>
	<a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=candidatepool&sorted_field=name&page=1&Itemid=<?php echo $this->Itemid; ?>">
		My candidate pool (<?php echo $total_candidate_in_pool; ?>)
	</a>
	</li>
	<li>
		<a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=messagelist&box=candidate_sent&sort=DESC&page=1&Itemid=". $this->Itemid; ?>">
			My message (<?php echo $total_unread_message;?>)
		</a>
	</li>
	</li>
	<li><a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=postjob&Itemid=". $this->Itemid; ?>">Job application</a></li>
	<li><a href="#" >Search CV</a></li>
</ul>
